﻿using BaseDll;
using CommonTools;
using StationDemo.设备信息.helper;
using Sunny.UI;
using System;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using UserData;

namespace StationDemo
{
    public partial class Form_ManualTable : UIPage
    {
        public Form_ManualTable(string name)
        {
            InitializeComponent();
        }

        private void Function_遍历控件(Control control)
        {
            foreach (var item in control.Controls)
            {
                if (item is Interface_UserControl)
                {
                    ((Interface_UserControl)item).Init();
                }
                else
                {
                    Function_遍历控件((Control)item);
                }
            }
        }

        private void Form_Manual转盘_Load(object sender, EventArgs e)
        {
            Function_遍历控件(this);
        }

        private void uiButtonSetEVATE_Click(object sender, EventArgs e)
        {
            if (!StationHelper.Station_Table.Function_Set平行光管参数())
            {
                UIMessageBox.ShowError("平行光管参数设置失败");
            }
            else
            {
                UIMessageBox.ShowSuccess("平行光管参数设置成功");
            }
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            if (UIMessageBox.ShowAsk("是否转到工位1到上料位"))
            {
                try
                {
                    StationHelper.Station_Table.Function_转动转盘到上料位置(1);
                }
                catch (Exception ex)
                {
                    UIMessageBox.ShowError(ex.Message);
                }
            }
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            if (UIMessageBox.ShowAsk("是否转到工位2到上料位"))
            {
                try
                {
                    StationHelper.Station_Table.Function_转动转盘到上料位置(2);
                }
                catch (Exception ex)
                {
                    UIMessageBox.ShowError(ex.Message);
                }
            }
        }

        private void uiButton3_Click(object sender, EventArgs e)
        {
            if (UIMessageBox.ShowAsk("是否转到工位3到上料位"))
            {
                try
                {
                    StationHelper.Station_Table.Function_转动转盘到上料位置(3);
                }
                catch (Exception ex)
                {
                    UIMessageBox.ShowError(ex.Message);
                }
            }
        }

        private void uiButton4_Click(object sender, EventArgs e)
        {
            if (UIMessageBox.ShowAsk("是否转到工位4到上料位"))
            {
                try
                {
                    StationHelper.Station_Table.Function_转动转盘到上料位置(4);
                }
                catch (Exception ex)
                {
                    UIMessageBox.ShowError(ex.Message);
                }
            }
        }
    }
}
